-
Notifications
You must be signed in to change notification settings - Fork 80
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor media type sniffing #377
Conversation
readium/streamer/src/main/java/org/readium/r2/streamer/parser/PublicationParser.kt
Outdated
Show resolved
Hide resolved
@@ -118,7 +119,7 @@ class ReaderRepository( | |||
val readerInitData = when { | |||
publication.conformsTo(Publication.Profile.AUDIOBOOK) -> | |||
openAudio(bookId, publication, initialLocator) | |||
publication.conformsTo(Publication.Profile.EPUB) -> | |||
publication.conformsTo(Publication.Profile.EPUB) || publication.readingOrder.allAreHtml -> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To support Readium Web Publication with HTML resources such as https://readium.org/webpub-manifest/examples/MobyDick/manifest.json
?.let { File(it).extension } | ||
?: "tmp" | ||
val file = File(dir, "$filename.$extension") | ||
val file = File(dir, "$filename.${extension(context)}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The extension
was missing from the URL in the case of a content
scheme. This made the format sniffing more expensive.
...src/main/java/org/readium/r2/shared/publication/protection/AdeptFallbackContentProtection.kt
Outdated
Show resolved
Hide resolved
readium/shared/src/main/java/org/readium/r2/shared/resource/BytesResource.kt
Outdated
Show resolved
Hide resolved
readium/shared/src/main/java/org/readium/r2/shared/util/http/DefaultHttpClient.kt
Outdated
Show resolved
Hide resolved
readium/shared/src/main/java/org/readium/r2/shared/util/mediatype/MediaType.kt
Show resolved
Hide resolved
readium/shared/src/main/java/org/readium/r2/shared/util/mediatype/MediaTypeSnifferContext.kt
Outdated
Show resolved
Hide resolved
600e5f9
to
1c8d360
Compare
MediaType
is now a simple class likeUrl
andHref
with no additional information about the format (file extension, name).MediaTypeHints
bundlesfileExtensions
andmediaTypes
hints together, to avoid the explosion of APIs for all the various hints combinations, and also to make it clear when amediaTypes
property is actually for hints.FormatRegistry
is used to register known media type file extensions.MediaTypeRetriever
is simplified to delegate the asset opening to theAssetRetriever
.MediaTypeRetriever
for fine-tuned sniffing and then provide a canonicalmediaType
as output. Apps are encouraged to use this instead of relying on a centralMediaTypeRetriever
supporting all cases.Resource
/Container
from the media type "module".